<template>
	<view class="content">
		<view style="padding: 14rpx;">
			<uni-row>
				<uni-col :span="24">
					<view style="margin-left: 8rpx;">
						<uni-easyinput class="uni-mt-5" trim="all" v-model="parameter.searchKey" prefixIcon="search"
							placeholder="请输入内容" @input="input($event)"></uni-easyinput>
					</view>
				</uni-col>
			</uni-row>
		</view>
		<view style="background-color: #999;">
			<uni-card :is-shadow="false" is-full class="forms_rows" v-for="item in dataList" :key="item.id"
				@click="details(item.id)">
				<view class="forms_label">
					药品名称： {{item.name}}
				</view>
				<view style="display: flex; justify-content: space-between;">
					<view>
						<view class="forms_label">
							规格：{{item.specification}}
						</view>

					</view>
					<uni-icons class="froms_icons" type="forward"></uni-icons>
				</view>
				<view class="forms_label">
					生产厂家：{{item.manufacturer}}
				</view>
			</uni-card>

		</view>
	</view>
</template>

<script setup>
	import {
		getpProcurement
	} from "./request.js"

	import {
		onReachBottom,
	} from '@dcloudio/uni-app';
	import {
		reactive,
		ref
	} from "vue";



	const parameter = reactive({
		current: 1,
		size: 10,
		searchKey: "",
	})

	onReachBottom((e) => {
		parameter.current += 1
		request()
	})

	const dataList = ref([])

	const request = () => {
		getpProcurement(parameter).then((res) => {
			let {
				records
			} = res.data
			console.log(res);
			dataList.value = [...dataList.value, ...records]
		})
	}
	request()

	const input = (e) => {
		dataList.value = []
		parameter.searchKey = e
		request()
	}

	const details = (id) => {
		uni.navigateTo({
			url: "/pages/view/addRecord/detailsPage?id=" + id,
		})
	}
</script>

<style lang="scss">
	.forms_rows {
		position: relative;
.forms_label{
	margin: 4rpx 0;
}
		.froms_icons {}
	}
</style>